#encoding=utf-8
#计算相邻数字相加的可能最大的和

def sum2(lnum):
    '''unittest
    >>> sum2([-1,11,-4,13,-5,2,-5,-3,12,-9])
    21
    >>> sum2([-1,1,0])
    1
    >>> sum2([-1,0,2])
    2
    >>> sum2([])        
    '''
    if not len(lnum):
        return None
    r = max(lnum)
    for i in xrange(len(lnum)):
        sum = 0
        for j in xrange(i, len(lnum)):
            sum += lnum[j]
            r = max(sum, r)
    return r
import doctest
doctest.testmod()